import 'package:flutter_app/Model/Enums.dart';
import 'package:flutter_app/Model/ProductModel.dart';
import 'package:flutter_yfree/main/YFree+Model.dart';

class ShouYeTJModel {
  ShouYeTJModel();

  late List<ShouYeTJModel_Banner> funcs;
  late List<ShouYeTJModel_Banner> banners_big;
  late List<ShouYeTJModel_Banner> banners_small_left;
  late List<ShouYeTJModel_Banner> banners_small_right;
  late List<ProductListSubModel> productItems;

  ShouYeTJModel.fromJson(Map<dynamic, dynamic> map) {
    funcs = map.byList("funcs", (rawValue) => ShouYeTJModel_Banner.fromJson(rawValue), defaultValue: [])!;
    banners_big = map.byList("banners_big", (rawValue) => ShouYeTJModel_Banner.fromJson(rawValue), defaultValue: [])!;
    banners_small_left = map.byList("banners_small_left", (rawValue) => ShouYeTJModel_Banner.fromJson(rawValue), defaultValue: [])!;
    banners_small_right = map.byList("banners_small_right", (rawValue) => ShouYeTJModel_Banner.fromJson(rawValue), defaultValue: [])!;
    productItems = map.byList("productItems", (rawValue) => ProductListSubModel.fromJson(rawValue), defaultValue: [])!;
  }
}

class ShouYeTJModel_Banner {
  ShouYeTJModel_Banner();

  late String id;
  late String title;
  late String img;
  late Enum_IntentType type;

  ShouYeTJModel_Banner.fromJson(Map<dynamic, dynamic> map) {
    id = map.byString("id", defaultValue: "")!;
    title = map.byString("title", defaultValue: "")!;
    img = map.byString("img", defaultValue: "")!;
    type = map.byEnum("type", (rawValue) => Enum_IntentType.from(rawValue), defaultValue: Enum_IntentType.UnKnown)!;
  }
}

class ShouYeFLModel {
  ShouYeFLModel();

  late String title;
  late List<ShouYeFLModel_Group> groups;
  late bool isSelect;

  ShouYeFLModel.fromJson(Map<dynamic, dynamic> map) {
    title = map.byString("title", defaultValue: "")!;
    groups = map.byList("groups", (rawValue) => ShouYeFLModel_Group.fromJson(rawValue), defaultValue: [])!;
    isSelect = map.byBool("isSelect", defaultValue: false)!;
  }
}

class ShouYeFLModel_Group {
  ShouYeFLModel_Group();

  late String title;
  late List<ShouYeFLModel_Item> items;

  ShouYeFLModel_Group.fromJson(Map<dynamic, dynamic> map) {
    title = map.byString("title", defaultValue: "")!;
    items = map.byList("items", (rawValue) => ShouYeFLModel_Item.fromJson(rawValue), defaultValue: [])!;
  }
}

class ShouYeFLModel_Item {
  ShouYeFLModel_Item();

  late String id;
  late String title;
  late String img;

  ShouYeFLModel_Item.fromJson(Map<dynamic, dynamic> map) {
    id = map.byString("id", defaultValue: "")!;
    title = map.byString("title", defaultValue: "")!;
    img = map.byString("img", defaultValue: "")!;
  }
}
